import {base, axiosInstance} from '@/api/config'

/*
 *登陆登出及授权
 */
const sysLogin = params => {return axiosInstance.post(`${base}/sys/login`, params).then(res => res.data);};
const sysLogout = params => {return axiosInstance.get(`${base}/sys/logout`, {params: params});};
const sysUserAuthority = params => {return axiosInstance.get(`${base}/sys/userAuthority`, {params: params});};
const sysModifyPassword = (params) => {return axiosInstance.put(`${base}/sysuser/updateUserPassword`,params)};
/*
 *机构部门管理
 */
const orgList = params => {return axiosInstance.get(`${base}/sysorg/list`, {params: params});};
const orgSave = params => {return axiosInstance.post(`${base}/sysorg/save`, params);};
const orgUpdate = params => {return axiosInstance.put(`${base}/sysorg/update`, params);};
const orgDelete = params => {return axiosInstance.delete(`${base}/sysorg/delete`, {data: params});};
const orgSelect = params => {return axiosInstance.get(`${base}/sysorg/select`, {params: params});}; //机构下拉列表
const orgRecover = params => {return axiosInstance.put(`${base}/sysorg/recover`, {params: params});}; //启用
const orgStop = params => {return axiosInstance.put(`${base}/sysorg/stop`, {params: params});}; //停用

/*
 *员工信息管理
 */
const userDelete = params => {return axiosInstance.delete(`${base}/sysuser/delete`, {data: params});};
const userList = params => {return axiosInstance.get(`${base}/sysuser/list`, {params: params});};
const userSave = params => {return axiosInstance.post(`${base}/sysuser/save`, params);};
const userUpdate = params => {return axiosInstance.put(`${base}/sysuser/update`, params);};
const userSelectUserForPay = params => {return axiosInstance.get(`${base}/sysuser/getUserForPay`, {params: params});}; //查询缴费人id和姓名
const userSelect = params => {return axiosInstance.get(`${base}/sysuser/select/${params}`);};//根据员工类型查询员工
const userSelectUserType = params => {return axiosInstance.get(`${base}/sysuser/selectUserType`, {params: params});}; //查询员工类型
const userUpdatePassword = params => {return axiosInstance.put(`${base}/sysuser/updatePassword`, params);}; //管理员修改密码
const userUpdateUserPassword = params => {return axiosInstance.put(`${base}/sysuser/updateUserPassword`, params);}; //用户修改密码

/*
 *用户配置角色
 */
const userRoleList = params => {return axiosInstance.get(`${base}/sysuserrole/list/${params}`);}; //获取角色列表
const userRoleUpdate = params => {return axiosInstance.put(`${base}/sysuserrole/update`, params);}; //保存

/*
 *角色配置菜单
 */
const roleMenuList = params => {return axiosInstance.get(`${base}/sysrolemenu/list/${params}`);}; //列表
const roleMenuUpdate = params => {return axiosInstance.put(`${base}/sysrolemenu/update`, params);}; //保存

/*
 *员工角色管理
 */
const roleList = params => {return axiosInstance.get(`${base}/sysrole/list`, {params: params});};
const roleSave = params => {return axiosInstance.post(`${base}/sysrole/save`, params);};
const roleDelete = params => {return axiosInstance.delete(`${base}/sysrole/delete`, {data: params});};
const roleUpdate = params => {return axiosInstance.put(`${base}/sysrole/update`, params);};

/*
 *菜单管理
 */
const menuList = params => {return axiosInstance.get(`${base}/sysmenu/list`, {params: params});};
const menuSave = params => {return axiosInstance.post(`${base}/sysmenu/save`, params);};
const menuUpdate = params => {return axiosInstance.put(`${base}/sysmenu/update`, params);};
const menuDelete = params => {return axiosInstance.delete(`${base}/sysmenu/delete`, {data: params});};

/*
 *日志管理
 */
const userLogList = params => {return axiosInstance.get(`${base}/sysuserlog/list`, {params: params});};
const userLogDelete = params => {return axiosInstance.delete(`${base}/sysuserlog/delete`, {data: params});};
const userLogExport = params => {return axiosInstance.get(`${base}/sysuserlog/export`, {params: params,responseType:'blob'});}; //导出

/*
 *居民用户删除
 */
const custDeleteIndSave = params => {return axiosInstance.post(`${base}/custdeleteind/save`,params);};
const custDeleteIndList = params => {return axiosInstance.get(`${base}/custdeleteind/list`, {params: params});};

/*
 *工商业用户删除
 */
const custDeleteEntSave = params => {return axiosInstance.post(`${base}/custdeleteent/save`,params);};
const custDeleteEntList = params => {return axiosInstance.get(`${base}/custdeleteent/list`, {params: params});};
/*调整补偿系数*/
//查询
const gasfeeCoefficientList = params => {return axiosInstance.get(`${base}/custent/list_gasfeeCoefficient`,{params:params});};
//修改
const gasfeeCoefficientUpdate = params => {return axiosInstance.put(`${base}/meterreadingent/update_gasfeeCoefficient`, params);};

/*月度抄表数据生成*/
//生成居民抄表数据
const meterReadingCreateInd = () => {return axiosInstance.post(`${base}/meterreadingind/createBatch`);};
//生成工商业抄表数据
const meterReadingCreateEnt = () => {return axiosInstance.post(`${base}/meterreadingent/createBatch`);};

/*
 *小区建筑信息
 */
  const codeBuildinfoDelete = params => {return axiosInstance.delete(`${base}/codebuildinfo/delete`, {data: params});}; //删除
  const codeBuildinfoList = params => {return axiosInstance.get(`${base}/codebuildinfo/list/${params}`);}; //列表查看
  const codeBuildinfoSave = params => {return axiosInstance.post(`${base}/codebuildinfo/save`, params);}; //新增
  const codeBuildinfoUpdate  = params => {return axiosInstance.put(`${base}/codebuildinfo/update`, params);}; //修改

//发票审核人配置-详情查看
const auditorConfigSelect = params => {return axiosInstance.get(`${base}/codeauditorconfig/select`);};
//发票审核人配置-修改
const auditorConfigUpdate = params => {return axiosInstance.put(`${base}/codeauditorconfig/update/${params}`);};

let system = {
  sys: { //登录登出及授权
    login: sysLogin,
    logout: sysLogout,
    userAuthority: sysUserAuthority,
    modifyPassword:sysModifyPassword
  },
  org: { //机构部门管理
    list: orgList,
    save: orgSave,
    update: orgUpdate,
    delete: orgDelete,
    select: orgSelect,
    recover: orgRecover, //启用
    stop: orgStop //停用
  },
  user: { //员工信息管理
    delete: userDelete,
    list: userList,
    save: userSave,
    update: userUpdate,
    select: userSelect, //根据员工类型查询员工
    selectUserType: userSelectUserType, //查询员工类型
    updatePassword: userUpdatePassword, //管理员修改密码
    updateUserPassword: userUpdateUserPassword, //用户修改密码
    selectChargeUsers:userSelectUserForPay, //查询收费人员的id和名称
  },
  userRole: { //用户配置角色
    list: userRoleList,
    update:  userRoleUpdate
  },
  roleMenu: { //角色配置菜单
    list: roleMenuList,
    update: roleMenuUpdate,
  },
  role: { //员工角色管理
    list: roleList,
    save: roleSave,
    delete: roleDelete,
    update: roleUpdate
  },
  menu: { //菜单管理
    list: menuList,
    save: menuSave,
    update: menuUpdate,
    delete: menuDelete
  },
  userLog: { //日志管理
    list: userLogList,
    delete: userLogDelete,
    export: userLogExport //导出
  },
  custDeleteInd: { //居民用户删除
    save: custDeleteIndSave,
    list: custDeleteIndList
  },
  custDeleteEnt: { //工商业用户删除
    save: custDeleteEntSave,
    list: custDeleteEntList
  },
  gasfeeCoefficient:{ //调整补偿系数
    list:gasfeeCoefficientList,
    update:gasfeeCoefficientUpdate,
  },
  meterReadingCreate:{ //月度抄表数据生成
    meterReadingCreateInd: meterReadingCreateInd, //生成居民抄表数据
    meterReadingCreateEnt: meterReadingCreateEnt  //生成工商业抄表数据
  },
  codeBuildinfo: { //小区建筑信息
    delete: codeBuildinfoDelete, //删除
    list: codeBuildinfoList, //列表查看
    save: codeBuildinfoSave, //新增
    update: codeBuildinfoUpdate //修改
  },
  auditorConfig: { //发票审核人配置
    select: auditorConfigSelect, //详情查看
    update: auditorConfigUpdate, //修改
  }
};

export {system};
